
export default {
  StoreProductShow: {
    entity: { name: 'ProductShow', prefix: () => `store/${localStorage.getItem('storeId')}` },
    form: {
      fields: [
        'store',
        'title',
        {
          property: 'image',
          type: 'image',
          help: '有图片显示图片，没有图片显示标题'
        },
        {
          property: 'images',
          type: 'images',
          help: '有就显示轮播，没有就显示上面的图片'
        },
        {
          property: 'products',
          field_options: { label: '产品' },
          component: {
            props: ['form', 'property'],
            data() {
              return {
                products: []
              }
            },
            created() {
              this.axios.get(`/store/${localStorage.getItem('storeId')}/store-specifications`, {
                params: {
                  '@display': `{
                  'key': 'entity.getSpecification().getProduct().getId()',
                  'label': 'entity.getSpecification().getProduct().getName()'
                }`,
                  limit: 10000
                }
              }).then((res) => {
                console.log('res', res.data)
                this.products = res.data.filter((item, index, self) =>
                  index === self.findIndex((t) => t.key === item.key)
                )
              })
            },
            render(h) {
              return (
                <el-transfer filterable v-model={this.form[this.property]} data={this.products}></el-transfer>
              )
            }
          }
        },
        'listOrder',
        'enabled'
      ]
    },
    list: {
      list_display: [
        'store',
        'title',
        {
          property: 'image',
          type: 'image'
        },
        'products',
        {
          property: 'listOrder',
          editable: true
        },
        {
          property: 'enabled',
          editable: true
        }
      ]
    }
  }
}
